﻿using System.Linq;
using System.Collections.ObjectModel;

using MyWindowsMediaPlayer.Libs.Mediator;
using MyWindowsMediaPlayer.Libs.ViewModel;
using MyWindowsMediaPlayer.Models.Library;

namespace MyWindowsMediaPlayer.ViewModels.Library
{
	class MasterLibraryViewModel : ViewModelBase
	{
		#region Members

		readonly ReadOnlyCollection<LibraryItemViewModel> _items;
		readonly Mediator _mediator;
		
		#endregion

		#region Constructors

		public MasterLibraryViewModel ( Mediator mediator )
		{
			LibraryModel[ ] items = LibraryDatabase.InitData();

			this._mediator = mediator;

			this._items = new ReadOnlyCollection<LibraryItemViewModel>(
				(from item in items
				 select new LibraryItemViewModel(item, this._mediator))
					.ToList());
		}

		#endregion
		
		#region Accessors

		public ReadOnlyCollection<LibraryItemViewModel> Items
		{
			get { return this._items; }
		}
		
		#endregion
	}
}
